setwd("C:/data_blbc")
library(foreign) 
library(RItools)

options(scipen=999,digits=2)
anlist<-c("A5D","A6D","A5F", "A6F")
jlist<-c("ct")

for (j in jlist){
for (t in seq(0,100,by=50)){
##adjust t above for OA grade cutoffs for treatment (see .do file)
for (s in seq(2,2)){
for (a in anlist){

x<-paste("XBC",a,j,s,"sd",t,"tmn.dta",sep="")
afile<-read.dta(x)





xB0<-xBalance(tr~ps+usat+usae+sgat+sgae+dcat+dcae+lpat+lpae+clat+clae+elat+elae+li+ex+co+sqex+sqco+me, 
strata=factor(afile$st), data=afile, report=c("std.diffs","p.values"), na.rm=TRUE)




xB1<-xBalance(tr~ps+usat+usae+sgat+sgae+dcat+dcae+lpat+lpae+clat+clae+elat+elae+li+ex+co+sqex+sqco+me, 
strata=list(NOSTRATIFICATION=NULL), data=afile, report=c("std.diffs","p.values"), na.rm=TRUE)



print(x)
print("BALANCE PRE-MATCHING")
print(xB1,digits=2,show.pvals=TRUE)

print(x)
print("BALANCE POST-MATCHING")
print(xB0,digits=2,show.pvals=TRUE)




}
}
}
}

